﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace XNAFight.Characters.Core
{
    public class Dash
    {
        #region CHAMPS

        private int frame_duration;
        private int distance;
        private Vector2 translation;
        private int current_frame;
        private bool look_right;

        #endregion

        #region PROPRIETES

        public int FrameDuration
        {
            get { return frame_duration; }
            set { frame_duration = value; }
        }
        public int Distance
        {
            get { return distance; }
            set { distance = value; }
        }
        public Vector2 Translation
        {
            get { return translation; }
        }

        #endregion

        public Dash(int _distance, int _frame_duration)
        {
            distance = _distance;
            frame_duration = _frame_duration;
            translation = new Vector2();
        }

        public void init(bool _look_right)
        {
            current_frame = 0;
            look_right = _look_right;    
        }

        public bool update()
        {     
            // On parcours la distance pendant la premiere moitié
            if (current_frame < 0.5 * frame_duration)
            {
                translation.X = ((float)distance) / (0.5f * (float)frame_duration);
            }
            else
            {
                translation.X = 0;
            }

            if (!look_right)
                translation.X *= -1;


            current_frame++;

            if (current_frame == frame_duration)
                return false;

            return true;
        }
    }
}
